﻿@using BlazorMonaco;
@using Microsoft.AspNetCore.Components.Web
@inherits FeedbackComponent<string, bool>
<style>
    .my-editor-class {
        height: 85Vh
    }
</style>
@*<TextArea Style="height: 85vh; overflow: scroll;" Value="@seedData" />*@
<MonacoEditor Id="any-id-string" ConstructionOptions="EditorConstructionOptions" CssClass="my-editor-class" OnDidInit="x=>OnInit((MonacoEditor)x)" />
<HeadContent>
    <link href="_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.css" rel="stylesheet" />
</HeadContent>
@code {
    private string seedData = string.Empty;
    /// <summary>
    /// 页面初始化
    /// </summary>
    /// <returns></returns>
    protected override async Task OnInitializedAsync()
    {
        seedData = this.Options;
        await base.OnInitializedAsync();
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="editor"></param>
    private void OnInit(MonacoEditor editor)
    {
        editor.SetValue(seedData);
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="editor"></param>
    /// <returns></returns>
    private StandaloneEditorConstructionOptions EditorConstructionOptions(MonacoEditor editor)
    {
        return new StandaloneEditorConstructionOptions
            {
                AutomaticLayout = true,
                Language = "csharp"
            };
    }
}
